/**
 * 
 */
package com.dalonedrow.rpg.base.map;

import com.dalonedrow.engine.sprite.base.SimpleVector2;

/**
 * @author Donald
 *
 */
public class TileCell<T> implements Comparable {
	/**
	 * {@inheritDoc}
	 */
	public int compareTo(Object o) {
		int val = -1;
		if (o instanceof TileCell<?>) {
			if (y < ((TileCell<?>) o).y) {
				val = -1;
			} else if (y > ((TileCell<?>) o).y) {
				val = 1;
			} else {
				if (x < ((TileCell<?>) o).x) {
					val = -1;
				} else if (x > ((TileCell<?>) o).x) {
					val = 1;
				} else {
					val = 0;
				}
			}
		}
		return val;
	}
	/** the image associate with this cell. */
	private int imageRefId = -1;
	/** the tile type associate with this cell. */
	private TileTerrain type;
	/** the cell's x-position. */
	private int x;
	/** the cell's y-position. */
	private int y;
	/**
	 * Creates a new instance of Cell.java.
	 * @param newX the cell's x-position 
	 * @param newY the cell's y-position
	 */
	public TileCell(final int newX, final int newY) {
		this.x = newX;
		this.y = newY;
	}
	/**
	 * Gets the cell's image reference id.
	 * @return <code>int</code>
	 */
	public int getImageRefId() {
		return imageRefId;
	}
	/**
	 * Sets the cell's image reference id.
	 * @param val the cell's image reference id
	 */
	public void setImageRefId(final int val) {
		imageRefId = val;
	}
	/**
	 * Gets the cell's location.
	 * @return {@link SimpleVector2}
	 */
	public SimpleVector2 getLocation() {
		return new SimpleVector2(x, y);
	}
	/**
	 * Gets the cell's type.
	 * @return TerrainType
	 */
	public TileTerrain getType() {
		return type;
	}
	/**
	 * Gets the cell's x-position.
	 * @return int
	 */
	public int getX() {
		return x;
	}
	/**
	 * Gets the cell's y-position.
	 * @return int
	 */
	public int getY() {
		return y;
	}
	/**
	 * Sets the cell's tile type.
	 * @param newType the tile type associate with this cell
	 */
	public void setType(final TileTerrain newType) {
		this.type = newType;
	}
	/**
	 * Sets the cell's x-position.
	 * @param newX the cell's x-position
	 */
	public void setX(final int newX) {
		this.x = newX;
	}
	/**
	 * Sets the cell's y-position.
	 * @param newY the cell's y-position
	 */
	public void setY(final int newY) {
		this.y = newY;
	}

}
